package com.top.mall.jetpack.vm

import android.app.Application
import androidx.lifecycle.MutableLiveData
import com.module.lemlin.http.HttpResponseBody
import com.module.lemlin.http.HttpResponseData
import com.module.lemlin.http.SubscribeViewModel
import com.top.mall.base.BaseViewModel
import com.top.mall.entity.AddressResponse
import com.top.mall.entity.HomeIndexResponse
import com.top.mall.entity.LeaderResponse
import com.top.mall.jetpack.ma.HomeManager
import com.top.mall.jetpack.ma.MineManager

class MineViewModel(application: Application) : BaseViewModel(application) {
    private val mMineManager: MineManager = MineManager()

    val submitInvoiceVoidTaxLiveData = MutableLiveData<HttpResponseBody<HttpResponseData>>()
    fun submitInvoiceVoidTax(
        type: Int,
        tax_code: String,
        company_name: String,
        start_time: String,
        end_time: String,
        void_business_tax_img: String
    ) {
        setRxLifeScope(SubscribeViewModel(submitInvoiceVoidTaxLiveData)) {
            mMineManager.submitInvoiceVoidTax(
                type,
                tax_code,
                company_name,
                start_time,
                end_time,
                void_business_tax_img
            )
        }
    }

    val addressListLiveData = MutableLiveData<HttpResponseBody<AddressResponse>>()
    fun addressList() {
        setRxLifeScope(SubscribeViewModel(addressListLiveData)) {
            mMineManager.addressList()
        }
    }

    val leaderListLiveData = MutableLiveData<HttpResponseBody<LeaderResponse>>()
    fun leaderList() {
        setRxLifeScope(SubscribeViewModel(leaderListLiveData)) {
            mMineManager.leaderList()
        }
    }

    val saveAddressLiveData = MutableLiveData<HttpResponseBody<HttpResponseData>>()
    fun saveAddress(
        id: Int? = null,
        province: Int,
        city: Int,
        district: Int,
        address: String, is_default: Int
    ) {
        setRxLifeScope(SubscribeViewModel(saveAddressLiveData)) {
            mMineManager.saveAddress(id, province, city, district, address, is_default)
        }
    }

    val saveLeaderLiveData = MutableLiveData<HttpResponseBody<HttpResponseData>>()
    fun saveLeader(
        id: Int? = null,
        mobile: String,
        surname: String,
        user_name: String,
        id_card: String,
        birthday: String,
        is_default: Int
    ) {
        setRxLifeScope(SubscribeViewModel(saveLeaderLiveData)) {
            mMineManager.saveLeader(id, mobile, surname, user_name, id_card, birthday, is_default)
        }
    }
}